package design_pattern;

//责任链模式
public class ChainRespPattern {
    public static void main(String[] args) {
        Leader leader = new Leader();
        Boss boss = new Boss();
        leader.setNextHandler(boss);
        leader.process(11);
    }
}
abstract class Handler{
    protected Handler nextHandler;
    public void setNextHandler(Handler nextHandler){
        this.nextHandler = nextHandler;
    }
    public abstract void process(Integer info);
}
class Leader extends Handler{

    @Override
    public void process(Integer info) {
        if (info>0 && info<11){
            System.out.println("Leader 处理！");
        }else {
            nextHandler.process(info);//下一个处理链处理
        }
    }
}
class Boss extends Handler{

    @Override
    public void process(Integer info) {
        if (info>=11){
            System.out.println("结束");
        }
    }
}